#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void main()
{
    // 1.定义数组
    int arr1[3];
    arr1[0] = 0;
    arr1[1] = 1;
    arr1[2] = 2;
    for (int i = 0; i < sizeof(arr1) / 4; i++)
    {
        printf("%d ", arr1[i]);
    }
    //输出结果: 0 1 2

    // 2.声明数组
    int arr2[] = {1, 2, 3, 4, 5};
    // 这种情况下的，数组不需要定义大小。
    for (int i = 0; i < 5; i++)
    {
        printf("%d ", arr2[i]);
    }
    //输出结果: 1 2 3 4 5

    printf("\n");

    //也可以这样子定义数组
    int arr3[5] = {1, 2, 3}; //定义arr3数组有5个元素，但只有前三个元素赋值了，后两个元素系统自动赋值为0
    int arr4[10] = {0};      //未赋值的元素自动设置为0

    int arr5[3][3] = {1, 2, 3, 4, 5, 6};
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            printf("%d ", arr5[i][j]);
        }
        printf("\n");
    }
    printf("\n");
    // arr5[0] -- arr5[0][0]  arr5[0][1]  arr5[0][2]
    // arr5[1] -- arr5[1][0]  arr5[1][1]  arr5[1][2]
    // arr5[2] -- arr5[2][0]  arr5[2][1]  arr5[2][2]

    int arr6[2][3] = {{1, 2, 3},
                      {4, 5, 6}};
    int new_arr[3][2];
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            new_arr[j][i] = arr6[i][j];
        }
    }

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            printf("%d ", new_arr[i][j]);
        }
        printf("\n");
    }
    puts("hello word!");

    char str1[6] = "456";
    char str2[] = "123";
    strcat(str1, str2);
    printf("%s\n", str1);

    char str3[] = "qwe";
    char str4[] = "qwe1";

    if (strcmp(str3, str4) == 0)
    {
        printf("两个字符串相等\n");
    }
    else if (strcmp(str3, str4) > 0)
    {
        printf("str3>str4\n");
    }
    else if (strcmp(str3, str4) < 0)
    {
        printf("str3<str4\n");
    }

    char str5[10]="China";
    printf("str5_length:%d\n",strlen(str5));

    system("pause");
}